/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chelydra.sharelydra.server.ejb;

import java.util.Date;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author scallion
 */
@Entity
public class SLSNotification implements Serializable {

	public static final int FRIENDSHIP_PROPOSAL = 1;
	public static final int FRIENDSHIP_ACCEPTED = 3;
	public static final int FRIENDSHIP_DECLINED = 5;
	public static final int FRIENDSHIP_REMOVED = 11;
	public static final int NOTIFY_FILE = 21;

	/**
	 * Properties
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	private long createdTime;
	private Integer type;
	private String content;
	@ManyToOne 
	private SLSUser sender;
	@ManyToOne 
	private SLSUser receiver;

	/**
	 * Getters and Setters
	 */
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}

	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}

	public SLSUser getReceiver() {
		return receiver;
	}
	public void setReceiver(SLSUser receiver) {
		this.receiver = receiver;
	}

	public SLSUser getSender() {
		return sender;
	}
	public void setSender(SLSUser sender) {
		this.sender = sender;
	}

	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}

	public long getCreatedTime() {
		return createdTime;
	}
	public void setCreatedTime(long createdTime) {
		this.createdTime = createdTime;
	}

	public SLSNotification() {
	}

	public SLSNotification(Integer type, String content, SLSUser sender, SLSUser receiver) {
		this.setType(type);
		this.setContent(content);
		this.setSender(sender);
		this.setReceiver(receiver);
		this.setCreatedTime(new Date().getTime());
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof SLSNotification)) {
			return false;
		}
		SLSNotification other = (SLSNotification) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "chelydra.sharelydra.server.ejb.SLSNotification[id=" + id + "]";
	}

}
